Skip to content

fix: cache-buster hash is always 6 characters - #188

Open
CyberDex wants to merge 3 commits into
pixijs:mainfrom
CyberDex:fix/get-hash-padding
Open

CyberDex wants to merge 3 commits into
pixijs:mainfrom
CyberDex:fix/get-hash-padding

Conversation

@CyberDex

@CyberDex CyberDex commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Fixes #187

getHash converts the crc32 to hex without padding. When the crc32 has leading zeros (about 1 in 16 inputs), the hex string has an odd length, Buffer.from(hex, 'hex') drops the last digit, and the hash comes out 4 characters long instead of 6. Below 0x10 the hash is empty.

Changes

  • getHash pads the hex to 8 digits before decoding it.
  • A test in test/core/Utils.test.ts covers crc32 values with 1, 2 and 3 leading zero digits, and checks that hashes without a leading zero are unchanged. The test fails before the fix (expected 'n6td' to match /^[\w-]{6}$/) and passes after it.

Hashes that were already 6 characters don't change. Only files whose crc32 starts with a zero get renamed, once. In the Manifest tests this renames sprite-sDtC@0.5x.png, sprite-3CLG.webp and the spine textures. tps-Ktro9A-0@0.5x.png.json, dragon-VMxv5A@0.5x.atlas and dragon-672U@0.5x.webp.atlas change too, because they reference renamed textures, so their expected names are updated.

npm run test:lint and npm run test:types pass.

🤖 Generated with Claude Code

Fixes pixijs#187

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@CyberDex CyberDex left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :)

CyberDex and others added 2 commits November 10, 2026 11:18
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: cache-buster hash is 4 characters (or empty) when crc32 has leading zeros

1 participant